#include "funselectui.h"
#include "dcuinformation.h"
#include <QPushButton>

FunSelectUI::FunSelectUI(QWidget *parent) : QWidget(parent)
{
    setWindowFlags(Qt::FramelessWindowHint);
    setAutoFillBackground(true);
    QPalette background = palette();
    background.setBrush(QPalette::Window, QBrush(QPixmap(":/images/defaultUI.png")));
    setPalette(background);

    initSelectBtn();
}

void FunSelectUI::initSelectBtn()
{
    int total = 6;

    QStringList textList;
    textList << "音量设置"
             << "特殊广播"
             << "设备状态"
             << "分区"
             << "本机信息"
             << "设置"
             << "退出";

    for (int var = 0; var < total; ++var)
    {
        QPushButton *btn = new QPushButton(this);
        btn->setText(textList.at(var));
        btn->setFont(QFont(ZITI, 18, QFont::Normal));
        btn->setGeometry(QRect(80 + (130 + 100) * (var % 3), 100 + (80 + 50) * (var / 3), 150, 100));

        connect(btn, SIGNAL(clicked()), this, SLOT(selectBtnDone()));
    }

    QPushButton *btn = new QPushButton(this);
    btn->setText(textList.at(6));
    btn->setFont(QFont(ZITI, 18, QFont::Normal));
    btn->setGeometry(QRect(710, 10, 75, 50));

    connect(btn, SIGNAL(clicked()), this, SLOT(selectBtnDone()));
}

void FunSelectUI::selectBtnDone()
{
    QObject *    obj = QObject::sender();
    QPushButton *btn = qobject_cast<QPushButton *>(obj);

    emit pageInfo(btn->text());
}
